﻿using Colorful.Database;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Bson;
using Colorful.Models;
using MongoDB.Driver;

namespace Colorful.CMS.Core
{
    #region MongodbContext
    public class DbContext : MongodbContext
    {
        private IMongoDatabase _db;

        #region 初始化
        public DbContext(string server, string username, string password, string dbName)
            : base(server, username, password, dbName)
        {
            _db = this.Database;
        }
        public DbContext(string connStr, string dbName, string collectionPrefix = "")
            :base(connStr, dbName, collectionPrefix)
        {
            _db = this.Database;
        }
        #endregion

        #region Collections
        /// <summary>
        /// 标签
        /// </summary>
        public IMongoCollection<Models.Tag> Tags
        {
            get
            {
                return _db.GetCollection<Models.Tag>("Tag");
            }
        }
        /// <summary>
        /// 登陆日志
        /// </summary>
        public IMongoCollection<LoginHistory> LoginHistories
        {
            get
            {
                return _db.GetCollection<LoginHistory>("LoginHistory");
            }
        }
        /// <summary>
        /// 按日期UV PV统计
        /// </summary>
        public IMongoCollection<StatByDate> StatByDates
        {
            get
            {
                return _db.GetCollection<StatByDate>("StatByDate");
            }
        }
        /// <summary>
        /// 按访问页面统计
        /// </summary>
        public IMongoCollection<StatByPage> StatByPages
        {
            get
            {
                return _db.GetCollection<StatByPage>("StatByPage");
            }
        }
        /// <summary>
        /// 按域名统计
        /// </summary>
        public IMongoCollection<StatByDomain> StatByDomains
        {
            get
            {
                return _db.GetCollection<StatByDomain>("StatByDomain");
            }
        }
        /// <summary>
        /// 按国家统计
        /// </summary>
        public IMongoCollection<StatByCountry> StatByCountries
        {
            get
            {
                return _db.GetCollection<StatByCountry>("StatByCountry");
            }
        }
        /// <summary>
        /// 按地区统计
        /// </summary>
        public IMongoCollection<StatByArea> StatByAreas
        {
            get
            {
                return _db.GetCollection<StatByArea>("StatByArea");
            }
        }
        /// <summary>
        /// 报表安排
        /// </summary>
        public IMongoCollection<ReportSchedule> ReportSchedules
        {
            get
            {
                return _db.GetCollection<ReportSchedule>("ReportSchedule");
            }
        }
        /// <summary>
        /// 文章缓存
        /// </summary>
        public IMongoCollection<ArticleCache> ArticleCaches
        {
            get
            {
                return _db.GetCollection<ArticleCache>("ArticleCache");
            }
        }
        /// <summary>
        /// 留言板
        /// </summary>
        public IMongoCollection<Guestbook> Guestbooks
        {
            get
            {
                return _db.GetCollection<Guestbook>("Guestbook");
            }
        }
        /// <summary>
        /// 计数器
        /// </summary>
        public IMongoCollection<Counter> Counters
        {
            get
            {
                return _db.GetCollection<Counter>("Counter");
            }
        }
        /// <summary>
        /// 资源表
        /// </summary>
        public IMongoCollection<Resource> Resources
        {
            get
            {
                return _db.GetCollection<Resource>("Resource");
            }
        }
        /// <summary>
        /// 邮件
        /// </summary>
        public IMongoCollection<MailTemplate> MailTemplates
        {
            get
            {
                return _db.GetCollection<MailTemplate>("MailTemplate");
            }
        }
        /// <summary>
        /// 权限
        /// </summary>
        public IMongoCollection<Role> Roles
        {
            get
            {
                return _db.GetCollection<Role>("Roles");
            }
        }
        /// <summary>
        /// 文章
        /// </summary>
        public IMongoCollection<Article> Articles
        {
            get
            {
                return _db.GetCollection<Article>("Article");
            }
        }
        /// <summary>
        /// 标签表
        /// </summary>
        public IMongoCollection<Colorful.Models.Label> Labels
        {
            get
            {
                return _db.GetCollection<Colorful.Models.Label>("Label");
            }
        }
        /// <summary>
        /// 友情链接
        /// </summary>
        public IMongoCollection<Link> Links
        {
            get
            {
                return _db.GetCollection<Link>("Link");
            }
        }
        /// <summary>
        /// 菜单
        /// </summary>
        public IMongoCollection<Menu> Menus
        {
            get
            {
                return _db.GetCollection<Menu>("Menus");
            }
        }
        /// 菜单模块
        /// </summary>
        public IMongoCollection<MenuModule> MenuModules
        {
            get
            {
                return _db.GetCollection<MenuModule>("MenuModule");
            }
        }
        /// <summary>
        /// 模板
        /// </summary>
        public IMongoCollection<Template> Templates
        {
            get
            {
                return _db.GetCollection<Template>("Template");
            }
        }
        /// <summary>
        /// 管理员表
        /// </summary>
        public IMongoCollection<Administrator> Users
        {
            get
            {
                return _db.GetCollection<Administrator>("Administrator");
            }
        }
        /// <summary>
        /// 网站设置
        /// </summary>
        public IMongoCollection<WebSetting> WebSettings
        {
            get
            {
                return _db.GetCollection<WebSetting>("WebSettings");
            }
        }
        /// <summary>
        /// Email设置
        /// </summary>
        public IMongoCollection<EmailSetting> EmailSettings
        {
            get
            {
                return _db.GetCollection<EmailSetting>("EmailSetting");
            }
        }
        /// <summary>
        /// 缓存设置
        /// </summary>
        public IMongoCollection<WebCacheSetting> CacheSettings
        {
            get
            {
                return _db.GetCollection<WebCacheSetting>("CacheSetting");
            }
        }
        /// <summary>
        /// 权限
        /// </summary>
        public IMongoCollection<Permission> Permissions
        {
            get
            {
                return _db.GetCollection<Permission>("Permissions");
            }
        }
        /// <summary>
        /// 代码
        /// </summary>
        public IMongoCollection<Code> Codes
        {
            get
            {
                return _db.GetCollection<Code>("Code");
            }
        }
        /// <summary>
        /// 验证表
        /// </summary>
        public IMongoCollection<Verification> Verifications
        {
            get
            {
                return _db.GetCollection<Verification>("Verification");
            }
        }
        /// <summary>
        /// 国家列表
        /// </summary>
        public IMongoCollection<Country> Countries
        {
            get
            {
                return _db.GetCollection<Country>("Country");
            }
        }
        /// <summary>
        /// 国家Json数据
        /// </summary>
        public IMongoCollection<CountryJson> CountryJson
        {
            get
            {
                return _db.GetCollection<CountryJson>("CountryJson");
            }
        }
        /// <summary>
        /// 系统设置
        /// </summary>
        public IMongoCollection<SysSetting> SysSettings
        {
            get
            {
                return _db.GetCollection<SysSetting>("SysSetting");
            }
        }
        /// <summary>
        /// 垃圾箱
        /// </summary>
        public IMongoCollection<Trash> Trashs
        {
            get
            {
                return _db.GetCollection<Trash>("Trash");
            }
        }
        /// <summary>
        /// 操作历史
        /// </summary>
        public IMongoCollection<ActionHistory> ActionHistories
        {
            get
            {
                return _db.GetCollection<ActionHistory>("ActionHistory");
            }
        }
        /// <summary>
        /// 错误日志
        /// </summary>
        public IMongoCollection<ErrorLog> ErrorLogs
        {
            get
            {
                return _db.GetCollection<ErrorLog>("ErrorLog");
            }
        }
        /// <summary>
        /// 短消息
        /// </summary>
        public IMongoCollection<Message> Messages
        {
            get
            {
                return _db.GetCollection<Message>("Message");
            }
        }
        /// <summary>
        /// 公告
        /// </summary>
        public IMongoCollection<Notice> Notices
        {
            get
            {
                return _db.GetCollection<Notice>("Notice");
            }
        }
        /// <summary>
        /// 按UV PV统计
        /// </summary>
        public IMongoCollection<Statistic> Statistics
        {
            get
            {
                return _db.GetCollection<Statistic>("Statistic");
            }
        }
        /// <summary>
        /// 网站访客信息
        /// </summary>
        public IMongoCollection<VisitorRecord> VisitorRecords
        {
            get
            {
                return _db.GetCollection<VisitorRecord>("VisitorRecord");
            }
        }
        /// <summary>
        /// UserAgent
        /// </summary>
        public IMongoCollection<UserAgent> UserAgents
        {
            get
            {
                return _db.GetCollection<UserAgent>("UserAgent");
            }
        }
        /// <summary>
        /// 第三方用户关系表
        /// </summary>
        public IMongoCollection<ThirdpartyUser> ThirdpartyUsers
        {
            get
            {
                return _db.GetCollection<ThirdpartyUser>("ThirdpartyUser");
            }
        }
        #endregion
    }
    #endregion
}
